package cn.anquing.study.qlexpress.demo;

import cn.anquing.study.qlexpress.beans.StrongerOperator;
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressContext;
import com.ql.util.express.instruction.op.OperatorBase;

/**
 * 如何使用OperatorBase
 * @author wangquanqing
 * @since 2021/2/23 10:39
 */
public class Demo9 {

    public static void main(String[] args) throws Exception {
        ExpressRunner runner = new ExpressRunner();
        OperatorBase op = new StrongerOperator("contextPut");
        runner.addFunction("contextPut",op);
        String exp = "contextPut('success','false');contextPut('error','错误信息');contextPut('warning','提醒信息')";
        IExpressContext<String, Object> context = new DefaultContext<String, Object>();
        context.put("success","true");
        Object result = runner.execute(exp,context,null,false,true);
        System.out.println(result);
        System.out.println(context);
    }
}
